import 'package:flutter/material.dart';
import 'package:flutter_app/components/layout.dart'
    '';

class CouponsPage extends StatefulWidget {
  @override
  _CouponsPageState createState() => _CouponsPageState();
}

List<Widget> getCoupons() {
  return [1].map((item) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
      decoration: BoxDecoration(
        image: DecorationImage(
          // alignment: Alignment(0.9, 0.5),
          image: AssetImage('assets/images/bg_coupon_gray.9.png'),
          fit: BoxFit.fill,
        ),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          RowBetween(children: [
            ColumnStart(children: [
              Row(
                children: [
                  Text(
                    '+2%',
                    style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold),
                  ),
                  SizedBox(
                    width: 5
                  ),
                  TagContainer('加息',color:Colors.grey)
                ],
              ),
              Text(
                'Matrixport 限时加息福利',
                style: TextStyle(color: Colors.grey, fontSize: 12),
              ),

            ]),
            Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                Text('2021-03-12',style: TextStyle(fontSize:12,color: Colors.blue),),
                Text('即将到期',style: TextStyle(fontSize:12,color: Colors.blue))
              ],
            )
          ]),
          SizedBox(height: 20,),
          Container(
            height: 35,
            child: RowBetween(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                TextButton(
                    onPressed: () {},
                    child: Text(
                      '使用条件',
                      style: TextStyle(fontSize: 13),
                    )),
                FlatButton(
                  height: 25,
                  minWidth: 60,
                  color: Colors.blueAccent,
                  textColor: Colors.white,
                  onPressed: () {},
                  child: Text('使用'),
                  shape: StadiumBorder(),
                )
              ]
            ),
          )
        ],
      ),
    );
  }).toList();
}

class _CouponsPageState extends State<CouponsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DarkHeadBar('我的优惠券', actions: [
        TextButton(
            onPressed: () {Navigator.pushNamed(context, '/coupon/invalid');},
            child: Text(
              '已失效',
              style: TextStyle(color: Colors.black),
            ))
      ]),
      body: RefreshIndicator(
        onRefresh: () async {},
        child: Container(
          margin: EdgeInsets.symmetric(vertical: 10.0),
          padding: const EdgeInsets.symmetric(horizontal: 20.0),
          child: ListView(
            children: getCoupons(),
          ),
        ),
      ),
    );
  }
}
